package com.bot.rf.entity;

/**
 * @program: report-form-demo
 * @description: 图书层架标实体类
 * @author: zyy
 * @create: 2021-02-25 11:09
 **/
public class BookLocation implements Comparable {

    /** 馆藏区域号 */
    private String areaNo;

    /** 楼层 */
    private int floorNo;

    /** 书架区域号 */
    private int columnNo;

    /** 排号 */
    private int rowNo;

    /** 列号 */
    private int shelfNo;

    /** 层号 */
    private int layerNo;

    /** 顺序号 */
    private int orderNo;

    /** 书格总数 */
    private int totalNum;

    public String getAreaNo() {
        return areaNo;
    }

    public void setAreaNo(String areaNo) {
        this.areaNo = areaNo;
    }

    public int getFloorNo() {
        return floorNo;
    }

    public void setFloorNo(int floorNo) {
        this.floorNo = floorNo;
    }

    public int getColumnNo() {
        return columnNo;
    }

    public void setColumnNo(int columnNo) {
        this.columnNo = columnNo;
    }

    public int getRowNo() {
        return rowNo;
    }

    public void setRowNo(int rowNo) {
        this.rowNo = rowNo;
    }

    public int getShelfNo() {
        return shelfNo;
    }

    public void setShelfNo(int shelfNo) {
        this.shelfNo = shelfNo;
    }

    public int getLayerNo() {
        return layerNo;
    }

    public void setLayerNo(int layerNo) {
        this.layerNo = layerNo;
    }

    public int getOrderNo() {
        return orderNo;
    }

    public void setOrderNo(int orderNo) {
        this.orderNo = orderNo;
    }

    public int getTotalNum() {
        return totalNum;
    }

    public void setTotalNum(int totalNum) {
        this.totalNum = totalNum;
    }

    public BookLocation() {
    }

    public BookLocation(int floorNo) {
        this.floorNo = floorNo;
    }

    public BookLocation(String... location) {
        this.areaNo = location[0];
        this.floorNo = Integer.parseInt(location[1]);
        this.columnNo = Integer.parseInt(location[2]);
        this.rowNo = Integer.parseInt(location[3]);
        this.shelfNo = Integer.parseInt(location[4]);
        this.layerNo = Integer.parseInt(location[5]);
        if (location.length > 6) {
            this.orderNo = Integer.parseInt(location[6]);
        }
        if (location.length > 7) {
            this.totalNum = Integer.parseInt(location[7]);
        }
    }

    public String getShelfLayerText() {
        return shelfNo + "架" + layerNo + "层";
    }

    public String getColumnRowText() {
        return columnNo + "列" + rowNo + "排";
    }

    @Override
    public int compareTo(Object o) {
        BookLocation bl = (BookLocation) o;
        int re;
        //排序，从楼层号到书架层号
        if (floorNo == bl.floorNo) {
            if (columnNo == bl.columnNo) {
                if (rowNo == bl.rowNo) {
                    if (shelfNo == bl.shelfNo) {
                        if (layerNo == bl.layerNo) {
                            if (orderNo == bl.orderNo) {
                                re = 0;
                            } else {
                                re = orderNo - bl.orderNo;
                            }
                        } else {
                            re = layerNo - bl.layerNo;
                        }
                    } else {
                        re = shelfNo - bl.shelfNo;
                    }
                } else {
                    re = rowNo - bl.rowNo;
                }
            } else {
                re = columnNo - bl.columnNo;
            }
        } else {
            re = floorNo - bl.floorNo;
        }
        return re;
    }
}
